import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'
import secondaryRouting from '../views/secondaryRouting/index'
import myFlowableRouter from './modules/myFlowable'
export const constantRoutes = [{
		path: '/redirect',
		component: Layout,
		hidden: true,
		children: [{
			path: '/redirect/:path*',
			component: () => import('@/views/redirect/index')
		}]
	},
	{
		path: '/login',
		component: () => import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/helpcenter',
		hidden: true,
		component: () => import('@/views/login/help'),
	},
	{
		path: '/updatePassword',
		component: () => import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/flowableFormEdit',
		component: Layout,
		hidden: true,
		children: [{
			path: '/',
			name: 'flowableFormEdit',
			component: () => import('@/views/flowable/form/edit'),
			meta: {
				title: '修改表单'
			}
		}]
	},
	{
		path: '/flowableModelEdit',
		component: Layout,
		hidden: true,
		children: [{
			path: '/',
			name: 'flowableModelEdit',
			component: () => import('@/views/flowable/model/edit'),
			meta: {
				title: '流程设计'
			},

		}]
	},
	{
		path: '/sysMenu',
		component: Layout,
		hidden: true,
		children: [{
			path: '/',
			name: 'sysMenu',
			component: () => import('@/views/sys/menu/index'),
			meta: {
				title: '系统'
			},

		}]
	},
	{
		path: '/mailDetails',
		component: Layout,
		hidden: true,
		children: [{
			path: '/',
			name: 'mailDetails',
			component: () => import('@/views/app/project/mailDetails'),
			meta: {
				title: '邮件信息'
			},

		}]
	},
	{
		path: '/404',
		component: () => import('@/views/exception/404'),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/workbench',
		children: [{
			path: '/workbench',
			name: 'workbench',
			component: () => import('@/views/workbench/index'),
			children: null,
			meta: {
				title: '工作台',
				icon: 'workbench',
				affix: true
			}
		}]
	},
	// {
	// 	path: "/my",
	// 	component: secondaryRouting,
	// 	hidden: false,
	// 	name: "My",
	// 	meta: {
	// 		"title": "我的",
	// 		"icon": "tools",
	// 		"isCache": true,
	// 		"affix": false
	// 	},
	// 	children: [
	// 		{
	// 			path: "myFlowable",
	// 			component: Layout,
	// 			hidden: false,
	// 			name: "MyFlowable",
	// 			meta: {
	// 				"title": "我的流程",
	// 				"icon": "tools",
	// 				"isCache": true,
	// 				"affix": false
	// 			},
	// 			children: [{
	// 				path: "myProcess",
	// 				redirect: "",
	// 				hidden: false,
	// 				name: "FlowableMyProcess",
	// 				component: () => import('@/views/flowable/myProcess/index'),
	// 				meta: {
	// 					"title": "我的汇总",
	// 					"icon": "list",
	// 					"isCache": true,
	// 					"affix": false
	// 				}
	// 			}, {
	// 				path: "myProcessQuery",
	// 				redirect: "",
	// 				hidden: true,
	// 				name: "FlowableMyProcessQuery",
	// 				component: () => import('@/views/flowable/myProcess/query'),
	// 				meta: {
	// 					"title": "我的流程",
	// 					"icon": "list",
	// 					"isCache": true,
	// 					"affix": false
	// 				}
	// 			}, {
	// 				path: "startMyProcess",
	// 				redirect: "",
	// 				hidden: false,
	// 				name: "FlowableStartMyProcess",
	// 				component: () => import('@/views/flowable/startMyProcess/index'),
	// 				meta: {
	// 					"title": "发起流程",
	// 					"icon": "list",
	// 					"isCache": true,
	// 					"affix": false
	// 				}
	// 			}, {
	// 				path: "taskTodo",
	// 				redirect: "",
	// 				hidden: false,
	// 				name: "FlowableTaskTodo",
	// 				component: () => import('@/views/flowable/taskTodo/index'),
	// 				meta: {
	// 					"title": "我的待办",
	// 					"icon": "list",
	// 					"isCache": true,
	// 					"affix": false
	// 				}
	// 			}, {
	// 				path: "taskRead",
	// 				redirect: "",
	// 				hidden: false,
	// 				name: "FlowableTaskToRead",
	// 				component: () => import('@/views/flowable/taskToRead/index'),
	// 				meta: {
	// 					"title": "我的待阅",
	// 					"icon": "list",
	// 					"isCache": true,
	// 					"affix": false
	// 				}
	// 			}, {
	// 				path: "taskDone",
	// 				redirect: "",
	// 				hidden: false,
	// 				name: "FlowableTaskDone",
	// 				component: () => import('@/views/flowable/taskDone/index'),
	// 				meta: {
	// 					"title": "我的已办",
	// 					"icon": "list",
	// 					"isCache": true,
	// 					"affix": false
	// 				}
	// 			}]
	// 		}
	// 	]
	// },
	// {
	// 	path: '/',
	// 	component: Layout,
	// 	redirect: '/dashboard',
	// 	hidden:true,
	// 	children: [{
	// 		path: '/dashboard',
	// 		name: 'dashboard',
	// 		component: () => import('@/views/dashboard/index'),
	// 		children: null,
	// 		meta: {
	// 			title: '首页',
	// 			icon: 'frontPage',
	// 			affix: true
	// 		}
	// 	}]
	// },
]

const createRouter = () => new Router({
	// 前后分离部署可使用history
	// mode: 'history',
	// 与springboot合并部署应改成hash，并把编译后文件夹dist下的文件全部拷贝到springboot工程路径:/src/main/resources/static
	mode: 'hash',
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})
const router = createRouter()

export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher
}

export default router
